var fs = require('fs')

function route(handle, pathname, response, params) {
    console.log(pathname);
    if (typeof handle[pathname] === 'function') {
        handle[pathname](response, params)
    } else {
        // console.log('no' + pathname);
        response.writeHead(200, {
            'Content-Type': "text/html"
        })
        fs.createReadStream(__dirname + "/404.html", "utf8").pipe(response)
        console.log("用户读取了购物车");
    }
}


module.exports.route = route